home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / doc / ptr_print.pro < prev    next >
Text File  |  1997-07-08  |  778b  |  29 lines

  1. ; PTR_PRINT accepts one arugument, a pointer to the first element
  2. ; of a linked list returned by PTR_READ. Note that the PTR_PRINT
  3. ; program does not need to know how many elements are in the list,
  4. ; nor does it need to explicitly know of any pointer other than the first.
  5.  
  6. PRO ptr_print, first
  7.  
  8. ; Create a second pointer to the heap variable pointed at by _first_.
  9.  
  10. current = first
  11.  
  12. ; PTR_VALID returns 0 if its argument is not a valid pointer.
  13. ; Note that the null pointer is not a valid pointer.
  14.  
  15. WHILE PTR_VALID(current) DO BEGIN
  16.  
  17.   ; Print the list element information.
  18.  
  19.   PRINT, current, ', named ', (*current).name, $
  20.       ', has a pointer to: ', (*current).next
  21.  
  22.   ; Set _current_ equal to the pointer in its own next field.
  23.  
  24.   current = (*current).next
  25.  
  26. ENDWHILE
  27.  
  28. END
  29.